import { mergeConfig, loadEnv } from 'vite'
import baseConfig from './vite.config.base'
export default ({ mode }) => {
  const { VITE_API_URL, VITE_API_BASE_URL } = loadEnv(mode, process.cwd())
  return mergeConfig(
    {
      mode: 'development',
      server: {
        open: true,
        host: '0.0.0.0',
        port: '5557',
        proxy: {
          [VITE_API_BASE_URL]: {
            // target: 'http://frp.signalpha.cn/',
            target: VITE_API_URL + '/api',
            changeOrigin: true,
            rewrite: path => path.replace(/^\/api/, ''),
          },
        },
      },
      plugins: [
        // eslint({
        //   cache: false,
        //   include: ['src/**/*.ts', 'src/**/*.tsx', 'src/**/*.vue'],
        //   exclude: ['node_modules'],
        // }),
      ],
    },
    baseConfig
  )
}
